package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsRegion;
import com.qf.service.RegionService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin("*")
@RequestMapping("/region")
public class RegionController {

    @Autowired
    private RegionService regionService;


    @RequestMapping("/list")
    public Object list(Integer page,Integer limit,String name,String code){
        IPage<DtsRegion> iPage = regionService.findByPage(page, limit, name, code);

        Map<String,Object> data = new HashMap<>();
        data.put("total",iPage.getTotal());
        data.put("items", iPage.getRecords());

        return ResponseUtil.ok(data);
    }
}
